﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
	Layout = null;
}
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Demo</title>
	<!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
	<link href="//unpkg.com/layui@2.9.18/dist/css/layui.css" rel="stylesheet">
</head>
<body>

	<form class="layui-form">
		<div class="layui-form-item">
			<div class="layui-inline">
				<table>
					<tr>
						<td>
							<label class="layui-form-label">订单编号</label>
							<div class="layui-input-inline layui-input-wrap">
								<input type="text" id="salesNo" name="salesNo" placeholder="订单编号" class="layui-input" style="width:300px;">
							</div>
						</td>

						<td>
							<div class="layui-form-item">
								<label class="layui-form-label">订单名称</label>
								<div class="layui-input-inline layui-input-wrap">
									<input type="text" id="salesName" name="salesName" placeholder="订单名称" class="layui-input" style="width:300px;">
								</div>
							</div>
						</td>

					</tr>

					<tr>
						<td>
							<div class="layui-form-item">
								<label class="layui-form-label">订单类型</label>
								<div class="layui-input-block">
									<select id="salesType" name="salesType" lay-filter="aihao" style="width:300px;">
										<option value="请选择">请选择</option>
										<option value="标准销售订单">标准销售订单</option>
										<option value="销售协议/报价">销售协议/报价</option>

									</select>
								</div>
							</div>
						</td>
						<td>
							<div class="layui-form-item">
								<label class="layui-form-label">所属项目</label>
								<div class="layui-input-block">
									<select id="salesItem" name="salesItem" lay-filter="aihao" style="width:300px;">
										<option value="">请选择</option>
										<option value="北京新项目">北京新项目</option>
										<option value="上海新项目">上海新项目</option>
										<option value="本部员工计算采购项目">本部员工计算采购项目</option>

									</select>
								</div>
							</div>
						</td>
					</tr>

					<tr>
						<td>
							<label class="layui-form-label">协议编码</label>
							<div class="layui-input-inline layui-input-wrap">
								<input type="text" id="agreementNum" name="agreementNum" placeholder="协议编码" class="layui-input" style="width:300px;">
							</div>
						</td>
						<td>
							<div class="layui-form-item">
								<label class="layui-form-label">协议名称</label>
								<div class="layui-input-inline layui-input-wrap">
									<input type="text" id="agreementName" name="agreementName" placeholder="协议名称" class="layui-input" style="width:300px;">
								</div>
							</div>
						</td>
					</tr>


					<tr>
						<td>
							<div class="layui-form-item layui-form-text">
								<label class="layui-form-label">订单备注</label>
								<div class="layui-input-block">
									<textarea placeholder="请输入内容" id="salesSmark" name="salesSmark" class="layui-textarea" style="width:300px;"></textarea>
								</div>
							</div>
						</td>
					</tr>

					<tr>
						<td>
							<label class="layui-form-label">客户</label>
							<div class="layui-input-block">
								<select id="salesPro" name="salesPro" lay-filter="aihao" style="width:300px;">
									<option value="">请选择</option>
									<option value="王天意">王天意</option>
									<option value="王丙鑫">王丙鑫</option>
									<option value="郑健义">郑健义</option>
									<option value="黄慧贤">黄慧贤</option>

								</select>
							</div>
						</td>
						<td>
							<label class="layui-form-label">订单金额（不含税）</label>
							<div class="layui-input-inline layui-input-wrap">
								<input type="text" id="salesMoney" name="salesMoney" placeholder="协议名称" class="layui-input" style="width:300px;">
							</div>
						</td>
					</tr>


					<tr>
						<td>
							<div class="layui-form-item">
								<label class="layui-form-label">币种</label>
								<div class="layui-input-block">
									<select id="moneyType" name="moneyType" lay-filter="aihao" style="width:300px;">
										<option value="">请选择</option>
										<option value="人民币">人民币</option>
										<option value="美元">美元</option>
										<option value="英镑">英镑</option>
									</select>
								</div>
							</div>
						</td>
						<td>
							<label class="layui-form-label">预收款金额</label>
							<div class="layui-input-block">
								<div class="layui-input-inline layui-input-wrap">
									<input type="text" id="moneyPlan" name="moneyPlan" placeholder="预收款金额" class="layui-input" style="width:300px;">
								</div>
							</div>
						</td>
					</tr>


					<tr>
						<td>
							<div class="layui-inline">
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">订单开始时间</label>
										<div class="layui-input-inline layui-input-wrap">
											<div class="layui-input-prefix">
												<i class="layui-icon layui-icon-date"></i>
											</div>
											<input type="date" name="salesSta" lay-verify="date" autocomplete="off" class="layui-input">
										</div>
									</div>
								</div>
							</div>
						</td>




						<td>
							<div class="layui-inline">
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">订单结束时间</label>
										<div class="layui-input-inline layui-input-wrap">
											<div class="layui-input-prefix">
												<i class="layui-icon layui-icon-date"></i>
											</div>
											<input type="date" name="salesEnd" lay-verify="date" autocomplete="off" class="layui-input">
										</div>
									</div>
								</div>
							</div>
						</td>

					</tr>

					<tr>
						<td>

							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">签订日期</label>
									<div class="layui-input-inline layui-input-wrap">
										<div class="layui-input-prefix">
											<i class="layui-icon layui-icon-date"></i>
										</div>
										<input type="date" name="salesSigned" lay-verify="date" autocomplete="off" class="layui-input">
									</div>
								</div>
							</div>
						</td>
						<td>
							<label class="layui-form-label">状态</label>
							<div class="layui-input-block">
								<div class="layui-input-inline layui-input-wrap">
									<input type="text" id="smark" name="smark" placeholder="预收款金额" style="width:300px;" class="layui-input">
								</div>
							</div>
						</td>
					</tr>

					<tr>
						<td>
							<div class="layui-form-item">
								<label class="layui-form-label">计税类型</label>
								<div class="layui-input-block">
									<select id="planTypes" name="planTypes" style="width:300px;" lay-filter="aihao">
										<option value="">请选择</option>
										<option value="增值税">增值税</option>
									</select>
								</div>
							</div>
						</td>
						<td>
							<label class="layui-form-label">税率</label>
							<div class="layui-input-block">
								<div class="layui-input-inline layui-input-wrap">
									<input type="text" id="tax" name="tax" placeholder="预收款金额" class="layui-input" style="width:300px;">
								</div>
							</div>
						</td>
					</tr>

					<tr>
						<td>
							<label class="layui-form-label">开票金额（含税）</label>
							<div class="layui-input-inline layui-input-wrap">
								<input type="text" id="startTax" name="startTax" placeholder="协议编码" class="layui-input" style="width:300px;">
							</div>
						</td>
						<td>
							<div class="layui-form-item">
								<label class="layui-form-label">已收款金额（含税）</label>
								<div class="layui-input-inline layui-input-wrap">
									<input type="text" id="showTax" name="showTax" placeholder="协议名称" class="layui-input" style="width:300px;">
								</div>
							</div>
						</td>

					</tr>


				</table>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button type="submit" class="layui-btn" lay-submit lay-filter="demo1">保存</button>
					</div>
				</div>

			</div>
		</div>
	</form>
</body>

</html>


<script>
	  layui.use(['form', 'laydate', 'util'], function () {
		var form = layui.form;


			var upload = layui.upload;

			var laypage = layui.laypage;
			var $ = layui.$;
			var layer = layui.layer;
			var util = layui.util;




			 // 表单取值
		layui.$('#component').on('click', function () {
			var data = form.val('demo-val-filter');
		});
		

		// 提交事件
		form.on('submit(demo1)', function (d) {
			var data = {
				salesId: $("#salesId").val(),
				salesNo: $("#salesNo").val(),
				salesName: $("#salesName").val(),
				salesType: $("#salesType").val(),
				salesItem: $("#salesItem").val(),
				agreementNum: $("#agreementNum").val(),
				agreementName: $("#agreementName").val(),
				salesSmark: $("#salesSmark").val(),
				salesPro: $("#salesPro").val(),
				salesMoney: $("#salesMoney").val(),
				moneyType: $("#moneyType").val(),
				moneyPlan: $("#moneyPlan").val(),
				salesSta: $("input[name='salesSta']").val(),
				salesEnd: $("input[name='salesEnd']").val(),
				salesSigned: $("input[name='salesSigned']").val(),
				smark: $("#smark").val(),
				planTypes: $("#planTypes").val(),
				tax: $("#tax").val(),
				startTax: $("#startTax").val(),
				showTax: $("#showTax").val(),

			};
			$.ajax({
				url:'@ViewBag.RBACWrite' + "/api/Sale/updateSale",
				type: 'put',
				data: JSON.stringify(data),
				dataType: "json",
				contentType: "application/json",
				success: res => {
					if (res.code == 0) {
						layer.msg('修改成功')
						 location.href = "ShowSale"
					}
					else {
						layer.msg('修改失败')
					}
				}
			})
			return false; // 阻止默认 form 跳转
		});

	});

	GetWorkCenter()

		//工作中心返填
		function GetWorkCenter() {
			var workCenterId = localStorage.getItem("salesId")       // 正确地使用冒号来定义对象属性
			console.log(workCenterId);
			$.ajax({
				url: '@ViewBag.RBACWrite' + "/api/Sale/FindSale",
				type: "post",
				data: JSON.stringify({ salesId: workCenterId }),
				dataType: "json",
				async: false,
				contentType: "application/json",
				success: function (res) {
					console.log(res);
					$(res.data).each(function () {
						console.log("返填数据", res.data);
						$("#salesId").val(this.salesId);
						$("#salesNo").val(this.salesNo);
						$("#salesName").val(this.salesName);
						$("#salesType").val(this.salesType);
						$("#salesItem").val(this.salesItem);
						$("#agreementNum").val(this.agreementNum);

						$("#agreementName").val(this.agreementName);
						$("#salesSmark").val(this.salesSmark);
						$("#salesPro").val(this.salesPro);
						$("#salesMoney").val(this.salesMoney);
						$("#moneyType").val(this.moneyType);
						$("#moneyPlan").val(this.moneyPlan);

						$("#salesSta").val(this.salesSta);
						$("#salesEnd").val(this.salesEnd);
						$("#salesSigned").val(this.salesSigned);
						$("#smark").val(this.smark);
						$("#planTypes").val(this.planTypes);
						$("#tax").val(this.tax);

						$("#startTax").val(this.startTax);
						$("#showTax").val(this.showTax);
					})
				}
			})
		}




</script>
@* <script>

		<table class="layui-table">
		<thead>
			<tr>
				<td>序号</td>
				<td>订单编码</td>
				<td>订单名称</td>
				<td>订单类型</td>
				<td>所属项目</td>
				<td>客户</td>
				<td>创建时间</td>
				<td>状态</td>
				<td>操作</td>
			</tr>
		</thead>

	</table>
</script> *@



